﻿/**
 * 获取包含全国省份信息的下拉框
 * @returns
 */
function provinceSelectHtml(selectId) {
	var provincesHtml = '';
	var e = $.ajax({
		type:"POST",
		url:"province/getList",
		async:false,
		dataType:'json',
		success:function(result){
			if(result){
				provincesHtml += '<option value="" selected = "selected" >全部</option>';
				for(var i=0; i<result.length; i++){
//					provincesHtml += '<option value="'+result[i].provinceid+'">'+result[i].province+'</option>';
					provincesHtml += '<option value="'+result[i].province+'">'+result[i].province+'</option>'; // 以省名称作为id
				}
			}
		}
	});
	return provincesHtml;
}

/**
 * 获取包含全国市区信息的下拉框，根据省id
 * @returns
 */
function citysSelectByProvinceIdHtml(provinceid){
	if(provinceid == ''){
		$("#deployCity").html('');
		return false;
	}
	var citysHtml = '';
	var e = $.ajax({
		type:"POST",
		url:"cities/getByProvinceid",
		async:false,
		data: {'provinceid': provinceid},
		dataType:'json',
		success:function(result){
			if(result){
				citysHtml += '<option value="" selected = "selected" ></option>';
				for(var i=0; i<result.length; i++){
					citysHtml += '<option value="'+result[i].city+'">'+result[i].city+'</option>'; // 以市名称作为id
				}
			}
		}
	});
	$("#deployCity").html(citysHtml);
}

/**
 * 获取包含全国市区信息的下拉框，根据省名称
 * @returns
 */
function citysSelectByProvinceNameHtml(province, num){
	if(province == ''){
		if(num == 1){
			$("#gameCity").html('');
		}else if(num == 2) {
			$("#deployCity").html('');
		}else if(num == 3){
			$("#registerCity").html('');
		}
		return false;
	}
	var cityId = "";
	if(num == 1){
		cityId = "gameCity";
	}else if(num == 2) {
		cityId = "deployCity";
	}else if(num == 3){
		cityId = "registerCity"
	}
	var citysHtml = '';
	var e = $.ajax({
		type:"POST",
		url:"cities/getByProvince",
		async:false,
		data: {'province': province},
		dataType:'json',
		success:function(result){
			if(result){
				//citysHtml += '<option value="" selected = "selected" ></option>';
				for(var i=0; i<result.length; i++){
					citysHtml += '<option value="'+result[i].city+'">'+result[i].city+'</option>'; // 以市名称作为id
				}
			}
		}
	});
	$("#"+cityId).html(citysHtml);
}